Introduction to
R/RStudio
Welcome!
Download R
and RStudio
-
Download R →
https://www.r-proj
ect.org/
-
Download RStudi
o →
https://rstudio
.com/products/rs
tudio/download/
-
See ELMS for
instructio
ns
What is R?
What is R?
“R is a language
and environment for
statistical computing
and graphics.”
-
Where you write code
-
What language you
write code in
What is RStudio?
“An integrated developm
ent
environment for
R
”
-
Where you write code
Both use R as
the coding
language
Both use Eng
lish
as the
language
Basically,
download
both
R & RStudio
but we will
mainl
y use
RStudio
Why learn progr
amming?
-
Make life easier
-
Analysis
-
Generate
pretty
graphics
Other fun/irrelevant
uses
-
Generate
random cat
fact
-
Generate
random
noise
s
-
Play rap musi
c
-
Tweet
-
Order
an Uber
Syllabus
General
Information
-
No programming
experienc
e required
-
No textbook
required
-
See syllabus for
online reso
urces
-
Google is
your friend
-
Slides, lecture c
ode, datasets
will be posted
Topics
-
Syntax
-
Functions
-
Data manip
ulation
-
Modeling
-
Statistical
significance
-
Figures
-
Packages
This class is a mix of
subjects
-
Biology
-
Examples we
do will be applic
ations of biolo
gy
-
Statistics
-
Some basic
statistics (p
-values,
linear reg
ression, t
-
test)
-
Computer progra
mming
Programming
101
-
Many coding
languages
-
R is one lang
uage
-
Write code
in
sc rip
t
-
Instructions
telling comput
er what
to do
-
Run script
-
Computer produ
ces output in
console
Genetic code
in
nucleus
tells
cell what
to do
Output: proteins
Computer
code
in
script
tell
s
computer what
to do
Output: values
All code is writt
en i
n a
script
Can change
the view
Editor vs Console
Run Code
Save your code!
All code is writt
en i
n a script
Editor vs Console
Run Code
Save your code!
Misc
-
You can code direc
tly into console
-
Commands
will be pre
ceded by “>”
-
But want to s
ave code togeth
er
-
Save your
script so you
can reuse
it!
Open previous
scripts
Open previous
scripts
Helpful
shortcuts
-
Ctrl+S/Cmd+S: save
code
-
Ctrl+L: cl
ears cons
ole
-
Ctrl+R: run
in R
-
Ctrl+Enter/Cmd+Return
:
run in RStudio
-
Ctrl+O/Cmd+O:
ope
n previous
script
-
https://support.rstudi
o.com/hc/en
-us/articles
/200711853
-
Keyboard-Shortcuts
Lesson
1: Commenting
-
Used to explain
what’s going on in your
code (English)
-
Computer
ignores the
se
-
Each line prece
ded by
#
-
#This is
a comment
Your turn: First In-Class
Exercise
-
Submit to ELMS the foll
owing information as
comments
-
#Name:
-
#Year:
-
#Major:
-
#Programming/statist
ics
experience?
-
#Anything you wish
to let me know about yoursel
f